import router from "@/router";
import { Cookie } from "./cookieSet";
import { GoPageName } from "@/enums";

// 导出一个函数，用于检查页面是否包含特定的路由信息
export function checkPage(url: string) {
  // 获取当前页面的路由路径
  const currentPath = url;
  const token = Cookie.getCookies('token');

  const keywords = ['competitionEntry', 'volunteerEntry', 'personalSetting'];
  const includesAny = keywords.some(keyword => currentPath.includes(keyword));
  if (includesAny && !token) {
    router.push({
      name: GoPageName.LOGIN, // 登录/找回密码等几个相似页面，路由都是login，根据path 判断显示哪个
      params: {
        path: GoPageName.LOGIN
      },
    })
  } else {
    return true
  }
}